#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>

using namespace std;

class Singleton{
friend class AutoRleaese;

public:
static Singleton * getInstance(){
    if(_s==nullptr){
        _s=new Singleton();
    }
    return _s;
}

private:
    Singleton(){}
    Singleton(const Singleton &)=delete;
    Singleton & operator=(const Singleton &)=delete;
    static Singleton *_s;
};
Singleton* Singleton::_s;

class AutoRleaese{
public:
    AutoRleaese(Singleton *s)
        :_s(s){

        }

    ~AutoRleaese(){
        if(_s){
            delete _s;
        }
    }
private:
    Singleton *_s;
};

void test(){
    AutoRleaese ar(Singleton::getInstance());
}

int main()
{
 test();
 return 0;
}

